package com.gouda.temporary.service;

import com.gouda.temporary.dao.TempHourOrdersMapper;
import com.gouda.temporary.vo.TempHourOrders;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 *
 */
@Service
public class TempHourOrdersService {

    @Resource
    private TempHourOrdersMapper tempHourOrdersMapper;

    /**
     * 根据主键ID查询
     */
    public TempHourOrders getTempHourOrdersById(Integer id) {
        return this.tempHourOrdersMapper.getTempHourOrdersById(id);
    }

    public TempHourOrders getTempHourOrdersByOrderNo(String order_no) {
        return this.tempHourOrdersMapper.getTempHourOrdersByOrderNo(order_no);
    }

    /**
     * 查询出所有记录
     */
    public List<TempHourOrders> findAllTempHourOrders() {
        return this.tempHourOrdersMapper.findAllTempHourOrders();
    }

    /**
     * 保存
     */
    public void saveTempHourOrders(TempHourOrders tempHourOrders) {
        this.tempHourOrdersMapper.saveTempHourOrders(tempHourOrders);
    }

    /**
     * 根据主键更新
     */
    public int updateTempHourOrders(TempHourOrders tempHourOrders) {
        return this.tempHourOrdersMapper.updateTempHourOrders(tempHourOrders);
    }

    public int updateOrderStatus(TempHourOrders tempHourOrders) {
        return this.tempHourOrdersMapper.updateOrderStatus(tempHourOrders);
    }

    /**
     * 根据主键删除
     */
    public void deleteTempHourOrders(Integer id) {
        this.tempHourOrdersMapper.deleteTempHourOrders(id);
    }

    /**
     * 得到业主下单
     * @param ownerId
     * @return
     */
    public List<TempHourOrders> getTempHourOrdersByOwnerId(String ownerId) {
        return this.tempHourOrdersMapper.getTempHourOrdersByOwnerId(ownerId);
    }

    /**
     * 得到小时工所有的订单
     * @param workerId
     * @return
     */
    public List<TempHourOrders> getTempHourOrdersByWorkerId(String workerId) {
        return this.tempHourOrdersMapper.getTempHourOrdersByWorkerId(workerId);
    }

    /**
     * 返回一个最新发布还没有被认领的任务单
     * @return
     */
    public TempHourOrders getNewsTempHourOrder(){
        return this.tempHourOrdersMapper.getNewsTempHourOrder();
    }

}
